package com.ruoyi.system.outto.goods.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttributeMapper;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoImgMapper;
import com.ruoyi.system.V2.inter.mapper.ArtRecMapper;
import com.ruoyi.system.model.domain.ArtRec;
import com.ruoyi.system.model.domain.GameAttribute;
import com.ruoyi.system.model.domain.GoodsInfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.dto.GoodsInfoAndAttrValueDto;
import com.ruoyi.system.model.service.UploadService;
import com.ruoyi.system.outto.core.MapUntils;
import com.ruoyi.system.outto.core.OutUrlConstant;
import com.ruoyi.system.outto.goods.NEWIPANZHIAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author sdq
 * @Date 2022/7/5 10:27
 */
@Slf4j
@Service
public class NEWPANZHIImpl implements NEWIPANZHIAPI {
    private static final String PZ_ADD_URL = "/api/openData/dataSync";
    private static final String PZ_MOD_URL = "/api/openData/updateGoodsPrice";
    private static final String PZ_DEL_URL = "/api/openData/downStandGoods";
    private static final String PZ_PROXY_ID = "15225247351";
//    private static final String PZ_PROXY_ID = "15225247351";

    //    private static final String PZ_PROXY_ID = "19153321403";
    @Resource
    private ArtRecMapper artRecMapper;
    @Value("${desc.title}")
    private String descTitle;
    @Resource
    private GoodsInfoImgMapper goodsInfoImgMapper;
    @Resource
    private UploadService uploadService;
    @Resource
    private GameAttributeMapper gameAttributeMapper;

    public static String getCover(Map<String, Object> params) {
        StringBuffer resut = new StringBuffer();
        for (String key : params.keySet()) {
            if (params.get(key) instanceof String && StringUtils.isNotEmpty((String) params.get(key))) {
                resut.append(key + "=" + params.get(key) + "&");
            }
            if (params.get(key) instanceof Boolean) {
                resut.append(key + "=" + params.get(key) + "&");
            }
            if (params.get(key) instanceof Long) {
                resut.append(key + "=" + params.get(key) + "&");
            }
            if (params.get(key) instanceof Integer && null != params.get(key)) {
                resut.append(key + "=" + params.get(key) + "&");
            }
        }
        return resut.toString();
    }

    //枪战王者 原神 英雄联盟 非合作游戏未测试
    private Map<String, Object> params(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner sa) {
        Map<String, Object> params = new HashMap<>();
        params.put("proxyId", null == sa.getOther() ? PZ_PROXY_ID : sa.getOther());
        Map<String, Object> action = new TreeMap<>();
        action.put("linkPhone", sa.getTwoOther());
        action.put("linkQq", sa.getTwoOther());
        action.put("linkWx", sa.getTwoOther());
        action.put("goodsCatalogueId", 6);
        action.put("gameAccount", goodsInfoAndAttrValueDto.getAccountNumber().substring(0,goodsInfoAndAttrValueDto.getAccountNumber().length()-1));
        action.put("gameSecret", goodsInfoAndAttrValueDto.getAccountPassword());
        action.put("accountSource", "ORIGINAL_USER");
        action.put("title", goodsInfoAndAttrValueDto.getTitle());//商品标题

        //盼之校验首图、上传首图 重新上传

        String imgTitle = goodsInfoAndAttrValueDto.getTitleImg();

        GoodsInfoImg goodsInfoImg = new GoodsInfoImg();
        goodsInfoImg.setGoodsId(goodsInfoAndAttrValueDto.getId());
        goodsInfoImg.setType(Constants.STR_1);
        List<GoodsInfoImg> infoImgs = goodsInfoImgMapper.selectGoodsInfoImgList(goodsInfoImg);

        if(sa.getSaleName().equals("PZZ_TIANKONG")){
            //随机账号图片
            action.put("gameAccount", goodsInfoAndAttrValueDto.getAccountNumber().substring(0,goodsInfoAndAttrValueDto.getAccountNumber().length()-1));
            imgTitle = infoImgs.get(0).getImgUrl();
        }

        action.put("goodsImg", imgTitle);
        action.put("price", goodsInfoAndAttrValueDto.getPrice().stripTrailingZeros().toPlainString());
        action.put("basePrice", goodsInfoAndAttrValueDto.getPrice().stripTrailingZeros().toPlainString());
        action.put("detailsSection1", goodsInfoAndAttrValueDto.getPrice().toPlainString());
        action.put("description", goodsInfoAndAttrValueDto.getDes());
        action.put("shotType", "ONESELF");
        action.put("compensation", true);
        action.put("bargain", true);
        action.put("outGoodsNo", String.valueOf(System.currentTimeMillis()).substring(5));
        action.put("sellRange", "ALL");
        action.put("gameSecret", "123456");
        action.put("detailsImages", new String[]{"https://game.ikbh.top/logo/no_img.jpg"});
        String imgUrls = infoImgs.stream().map(info -> info.getImgUrl()).collect(Collectors.toList()).stream().collect(Collectors.joining(","));
        if (StringUtils.isNotEmpty(imgUrls)) {

            List<String> list = Arrays.asList(imgUrls.split(","));
            if (!CollectionUtils.isEmpty(list)) {
                action.put("detailsImages", list.toArray());
            }
        }
        if ("绝地求生".equals(goodsInfoAndAttrValueDto.getGameName())){
            action.put("gameId", 22);
            action.put("single1", 6971);
        }
        else if (goodsInfoAndAttrValueDto.getGameName().equals("使命召唤手游")){
            action.put("gameId", 55);
            String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
            if ("安卓QQ".equals(regional)) {
                action.put("single1", 3725);//操作系统
            } else if ("苹果QQ".equals(regional)) {
                action.put("single1", 3727);//操作系统
            } else if ("安卓微信".equals(regional)) {
                action.put("single1", 3726);//操作系统
            } else if ("苹果微信".equals(regional)) {
                action.put("single1", 3728);//操作系统
            }
            action.put("detailsSingle1", 13724);
            action.put("detailsSingle2", 13962);
            action.put("single4", 3722);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                if(gameAttribute1.getFieldName().equals("可改实名")) {
                    action.put("single5", 3723);
                }else {
                    action.put("single5", 3724);
                }
            }else {
                action.put("single5", 3723);
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF6())){
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF6()));
                String string = "[{\"key\":3730,\"value\":\"青铜\"},{\"key\":3731,\"value\":\"白银\"},{\"key\":3732,\"value\":\"黄金\"},{\"key\":3733,\"value\":\"铂金\"},{\"key\":3734,\"value\":\"钻石\"},{\"key\":3735,\"value\":\"大师\"},{\"key\":3736,\"value\":\"战神\"},{\"key\":3737,\"value\":\"传奇战神\"}]\n";
                JSONArray jsonArray = JSONArray.parseArray(string);
                for(Object o : jsonArray){
                    if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(o.toString()).getString("value"))){
                        action.put("single6", JSONObject.parseObject(o.toString()).getInteger("key"));
                        break;
                    }
                }
            }else {
                action.put("single6", 3729);
            }
            action.put("single7", 5853);
        }
        else if ("无畏契约".equals(goodsInfoAndAttrValueDto.getGameName())){
            action.put("gameId", 231);
        }
        else if ("逆水寒".equals(goodsInfoAndAttrValueDto.getGameName())){
            action.put("gameId", 286);
            String areas = "[{\"id\":12902,\"name\":\"满江红\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":12903,\"name\":\"玄机喵算\",\"pid\":12902,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":12904,\"name\":\"万象玄机\",\"pid\":12902,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7733,\"name\":\"逐中原\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7746,\"name\":\"东京梦华\",\"pid\":7733,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7747,\"name\":\"挑灯看剑\",\"pid\":7733,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7748,\"name\":\"九天揽月\",\"pid\":7733,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7749,\"name\":\"铁马秋风\",\"pid\":7733,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7782,\"name\":\"应看千秋\",\"pid\":7733,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7736,\"name\":\"忆江南\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7737,\"name\":\"烟雨江南\",\"pid\":7736,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7738,\"name\":\"西子湖畔\",\"pid\":7736,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7739,\"name\":\"姑苏绮罗\",\"pid\":7736,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7740,\"name\":\"魔都风云\",\"pid\":7736,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7783,\"name\":\"碧海问舟\",\"pid\":7736,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7754,\"name\":\"将进酒\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7755,\"name\":\"群龙之首\",\"pid\":7754,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7756,\"name\":\"天下无双\",\"pid\":7754,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7757,\"name\":\"问鼎江湖\",\"pid\":7754,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7758,\"name\":\"武林萌主\",\"pid\":7754,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7784,\"name\":\"神龙九现\",\"pid\":7754,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7759,\"name\":\"踏北尘\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7760,\"name\":\"紫禁之巅\",\"pid\":7759,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7761,\"name\":\"武林天骄\",\"pid\":7759,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7762,\"name\":\"瑶光听雪\",\"pid\":7759,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7763,\"name\":\"帝都风云\",\"pid\":7759,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7785,\"name\":\"云川雪青\",\"pid\":7759,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7786,\"name\":\"如梦令\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7787,\"name\":\"江湖一梦\",\"pid\":7786,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7788,\"name\":\"刀剑如梦\",\"pid\":7786,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7789,\"name\":\"浮生若梦\",\"pid\":7786,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7790,\"name\":\"仲夏绮梦\",\"pid\":7786,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7791,\"name\":\"游园惊梦\",\"pid\":7786,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7792,\"name\":\"蝶恋花\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7793,\"name\":\"宿命相逢\",\"pid\":7792,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7794,\"name\":\"缘定三生\",\"pid\":7792,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7795,\"name\":\"明月天涯\",\"pid\":7792,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7796,\"name\":\"惊鸿照影\",\"pid\":7792,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7797,\"name\":\"踏月留香\",\"pid\":7792,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7798,\"name\":\"决南岭\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7799,\"name\":\"江山如画\",\"pid\":7798,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7800,\"name\":\"一蓑烟雨\",\"pid\":7798,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7801,\"name\":\"两广豪杰\",\"pid\":7798,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7802,\"name\":\"沧海月明\",\"pid\":7798,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7812,\"name\":\"君心如月\",\"pid\":7798,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7813,\"name\":\"逍遥游\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7814,\"name\":\"千古风流\",\"pid\":7813,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7815,\"name\":\"扶摇万里\",\"pid\":7813,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7816,\"name\":\"飞花逐月\",\"pid\":7813,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7817,\"name\":\"剑胆琴心\",\"pid\":7813,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7818,\"name\":\"白帝霜华\",\"pid\":7813,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7819,\"name\":\"定风波\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7820,\"name\":\"千里婵娟\",\"pid\":7819,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7821,\"name\":\"翩若惊鸿\",\"pid\":7819,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7822,\"name\":\"金风玉露\",\"pid\":7819,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7823,\"name\":\"佳期如梦\",\"pid\":7819,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7824,\"name\":\"雪泥鸿爪\",\"pid\":7819,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":7847,\"name\":\"望海潮\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7848,\"name\":\"日月同辉\",\"pid\":7847,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7849,\"name\":\"九州风雷\",\"pid\":7847,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7850,\"name\":\"满堂花醉\",\"pid\":7847,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7851,\"name\":\"凭栏听雨\",\"pid\":7847,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7852,\"name\":\"白夜拂雪\",\"pid\":7847,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]},{\"id\":6837,\"name\":\"凌西川\",\"pid\":0,\"gameId\":286,\"gamePropertyConfigName\":\"大区\",\"mappingField\":\"single1\",\"children\":[{\"id\":7719,\"name\":\"天府之国\",\"pid\":6837,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7720,\"name\":\"天外飞仙\",\"pid\":6837,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7750,\"name\":\"玲珑相思\",\"pid\":6837,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7751,\"name\":\"绝代风华\",\"pid\":6837,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]},{\"id\":7811,\"name\":\"燕字归时\",\"pid\":6837,\"gameId\":286,\"gamePropertyConfigName\":\"服务器\",\"mappingField\":\"single2\",\"children\":[]}]}]\n";
            JSONArray jsonArray = JSONArray.parseArray(areas);
            for(Object o : jsonArray){
                String children = JSONObject.parseObject(o.toString()).getString("children");
                JSONArray jsonArray1 = JSONArray.parseArray(children);
                for(Object p : jsonArray1){
                    if(goodsInfoAndAttrValueDto.getServerName().equals(JSONObject.parseObject(p.toString()).getString("name"))){
                        action.put("single1", JSONObject.parseObject(o.toString()).getString("id"));
                        action.put("single2", JSONObject.parseObject(p.toString()).getString("id"));
                        break;
                    }
                }
            }
            if(goodsInfoAndAttrValueDto.getCarrierName().equals("手机账号")) {
                action.put("single4", 7764);
            }else {
                action.put("single4", 7765);
            }
            action.put("single6", 12033);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                if(gameAttribute1.getFieldName().equals("男主")) {
                    action.put("single7", 7853);
                }else {
                    action.put("single7", 7854);
                }
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF1())){
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF1()));
                String string = "[{\"key\":12946,\"value\":\"玄机\"},{\"key\":7772,\"value\":\"碎梦\"},{\"key\":7773,\"value\":\"铁衣\"},{\"key\":10378,\"value\":\"龙吟\"},{\"key\":7774,\"value\":\"素问\"},{\"key\":7775,\"value\":\"血河\"},{\"key\":7776,\"value\":\"九灵\"},{\"key\":7777,\"value\":\"神相\"}]\n";
                JSONArray jsonArray1 = JSONArray.parseArray(string);
                for(Object o : jsonArray1){
                    if(JSONObject.parseObject(o.toString()).getString("value").equals(gameAttribute1.getFieldName())){
                        action.put("single5", JSONObject.parseObject(o.toString()).getString("value"));
                    }
                }
            }
            action.put("detailsSingle2", 13166);
            action.put("detailsSingle1", 13165);
        }
        else if("鸣潮".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 303);
            action.put("single1", 6971);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                if(gameAttribute1.getFieldName().equals("男主")) {
                    action.put("single4", 12751);
                }else {
                    action.put("single4", 12752);
                }
            }
        }
        else if ("金铲铲之战".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 25);
            String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
            if ("安卓QQ".equals(regional)) {
                action.put("single1", 1717);//操作系统
            } else if ("苹果QQ".equals(regional)) {
                action.put("single1", 1716);//操作系统
            } else if ("安卓微信".equals(regional)) {
                action.put("single1", 1718);//操作系统
            } else if ("苹果微信".equals(regional)) {
                action.put("single1", 1715);//操作系统
            }
            action.put("detailsSingle3", 13954);
            action.put("single4", 5849);

            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF6());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF7());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF8());
            List<GameAttribute> gameAttributs = getGameAttributs(pfIds);
            List list1 = new ArrayList();
            if(!CollectionUtils.isEmpty(gameAttributs)){
                String string = "[{\"key\":17859,\"value\":\"其他\"},{\"key\":17860,\"value\":\"电玩竞技场\"},{\"key\":17861,\"value\":\"独钓寒江雪\"},{\"key\":17862,\"value\":\"灵蛇补天石\"},{\"key\":17863,\"value\":\"2025浪漫礼堂\"},{\"key\":17864,\"value\":\"赛博都市顶点\"},{\"key\":17865,\"value\":\"枫桥夜泊\"}]\n";
                JSONArray jsonArray = JSONArray.parseArray(string);
                for(GameAttribute gameAttribute1 : gameAttributs){
                    for(Object o : jsonArray){
                        if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(o.toString()).getString("value"))){
                            list1.add(JSONObject.parseObject(o.toString()).getString("value"));
                        }
                    }
                }
            }
            if(CollectionUtils.isEmpty(list1)) {
                list1.add("其他");
            }
            action.put("detailsCheckbox1", list1);



            String cfyxk = "[{\"key\":13970,\"value\":\"至臻玉剑传说小小索拉卡\"},{\"key\":13971,\"value\":\"全球总决赛限定T1小小奥莉安娜\"},{\"key\":13972,\"value\":\"神凰行者小小萨勒芬妮\"}]\n";
            JSONArray jsonArray = JSONArray.parseArray(cfyxk);
            List<String> list = new ArrayList<>();
            if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                List<GameAttribute> strings = getGameAttributs(goodsInfoAndAttrValueDto.getF3());
                for (GameAttribute gameAttribute11 : strings) {
                    for (Object o : jsonArray) {
                        if (gameAttribute11.getFieldName().contains(JSONObject.parseObject(o.toString()).getString("value"))) {
                            list.add(JSONObject.parseObject(o.toString()).getString("value"));
                        }
                    }
                }
            }
            if(CollectionUtils.isEmpty(list)) {
                list.add("其他");
            }
            action.put("detailsCheckbox2", list);
            list = new ArrayList<>();
            list.add("其他");
            action.put("detailsCheckbox3", list);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())){
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF17()));
                String string = "[{\"key\":13726,\"value\":\"VIP11\"},{\"key\":13727,\"value\":\"VIP10\"},{\"key\":13728,\"value\":\"VIP9\"},{\"key\":13729,\"value\":\"VIP8\"},{\"key\":13730,\"value\":\"VIP7\"},{\"key\":13731,\"value\":\"VIP6\"},{\"key\":13732,\"value\":\"VIP5\"},{\"key\":13733,\"value\":\"VIP4\"},{\"key\":13734,\"value\":\"VIP3\"},{\"key\":13735,\"value\":\"VIP2\"},{\"key\":13736,\"value\":\"VIP1\"}]\n";
                JSONArray jsonArray2 = JSONArray.parseArray(string);
                for(Object o : jsonArray2){
                    if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(o.toString()).getString("value"))){
                        params.put("single5",JSONObject.parseObject(o.toString()).getString("key"));
                    }
                }
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF1())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF1()));
                if ("可二次实名".equals(gameAttribute1.getFieldName())) {
                    action.put("detailsSingle2", 7599);
                } else {
                    action.put("detailsSingle2", 7600);
                }
            }else {
                action.put("detailsSingle2", 7600);
            }
            action.put("single4", 5849);
        }
        else if ("王者荣耀".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action = wzryParams(goodsInfoAndAttrValueDto, action);
        }
        else if ("和平精英".equals(goodsInfoAndAttrValueDto.getGameName())) {
            GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
            action.put("gameId", 8);
            if ("可二次实名".equals(gameAttribute1.getFieldName())) {
                action.put("single4", 2167);
            } else if ("包人脸".equals(gameAttribute1.getFieldName())) {
                action.put("single4", 2562);
            } else {
                action.put("single4", 2168);
            }
            String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
            if ("安卓QQ".equals(regional)) {
                action.put("single1", 264);//操作系统
            } else if ("苹果QQ".equals(regional)) {
                action.put("single1", 265);//操作系统
            } else if ("安卓微信".equals(regional)) {
                action.put("single1", 266);//操作系统
            } else if ("苹果微信".equals(regional)) {
                action.put("single1", 267);//操作系统
            } else {
                action.put("single1", 1600);//操作系统
            }

            action.put("detailsCheckbox1", new String[]{"1759"});
            action.put("detailsSingle1", 1293);
            action.put("detailsSingle2", 12170);
            action.put("detailsSingle3", 13211);
            action.put("detailsSingle4", 13960);
            action.put("detailsText3", "0");
        }
        else if ("英雄联盟".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("section2", null == goodsInfoAndAttrValueDto.getF4() ? 0 : goodsInfoAndAttrValueDto.getF4());
            action.put("section1", 0);
            action.put("gameId", 6);
            action.put("single1", 1003);
            action.put("single2", 1004);
            action.put("detailsSingle1", 1293);
            action.put("detailsSingle4", 2586);
            GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF1()));
            if ("有修改人脸机会/实名是本人".equals(gameAttribute1.getFieldName())) {
                action.put("detailsSingle3", 2564);
            } else {
                action.put("detailsSingle3", 2566);
            }
        }
        else if ("原神".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 12);
            action.put("single1", 1082);
            action.put("single2", 1083);
            action.put("single4", 1282);
            action.put("single5", 1284);
            action.put("single6", 1286);
            action.put("single7", 2532);
            action.put("single8", 3512);
            action.put("detailsSingle1", 1293);
        }
        else if ("穿越火线".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 16);
            if (Objects.equals("东部战区", goodsInfoAndAttrValueDto.getGroupName())) {
                action.put("single1", 900);
            }
            if (Objects.equals("南部战区", goodsInfoAndAttrValueDto.getGroupName())) {
                action.put("single1", 901);
            }
            if (Objects.equals("西部战区", goodsInfoAndAttrValueDto.getGroupName())) {
                action.put("single1", 902);
            }
            if (Objects.equals("北部战区", goodsInfoAndAttrValueDto.getGroupName())) {
                action.put("single1", 903);
            }
            action.put("single2", 1090);
            action.put("single6", 11216);
            action.put("gameAccount", goodsInfoAndAttrValueDto.getAccountNumber());
            action.put("accountSource", "ORIGINAL_USER");
            action.put("detailsSingle1", 1293);
            GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
            if ("有修改人脸机会/实名是本人".equals(gameAttribute1.getFieldName())) {
                action.put("single7", "2551");
            } else {
                action.put("single7", "2552");
            }
            action.put("single5", "5840");
            String cfyxk = "[\n" +
                    "                {\n" +
                    "                    \"key\":7715,\n" +
                    "                    \"value\":\"火麒麟音效卡\"\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    \"key\":7716,\n" +
                    "                    \"value\":\"毁灭音效卡\"\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    \"key\":7717,\n" +
                    "                    \"value\":\"雷神音效卡\"\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    \"key\":7718,\n" +
                    "                    \"value\":\"无\"\n" +
                    "                }\n" +
                    "            ]";
            JSONArray jsonArray = JSONArray.parseArray(cfyxk);
            List<String> list = new ArrayList<>();
            if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF20())) {
                List<GameAttribute> strings = getGameAttributs(goodsInfoAndAttrValueDto.getF20());
                for (GameAttribute gameAttribute11 : strings) {
                    for (Object o : jsonArray) {
                        if (gameAttribute11.getFieldName().contains(JSONObject.parseObject(o.toString()).getString("value"))) {
                            list.add(JSONObject.parseObject(o.toString()).getString("value"));
                        }
                    }
                }
            } else {
                list.add("7718");
            }
            action.put("detailsCheckbox1", list);

            action.put("title", goodsInfoAndAttrValueDto.getDes());
            action.put("goodsImg", goodsInfoAndAttrValueDto.getTitleImg());
            action.put("description", goodsInfoAndAttrValueDto.getDes());
            action.put("shotType", "ONESELF");
            action.put("single4", "4834");
            action.put("goodsCatalogueId", 6);
            action.put("bargain", true);
            action.put("compensation", true);
        }
        else if ("枪战王者".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 10);
            action.put("accountSource", "ORIGINAL_USER");

            action.put("single5", "11219");
            action.put("detailsSingle1", "1335");
            action.put("detailsSingle2", "13955");
            action.put("single4", "5841");
            GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
            if ("可修改实名".contains(gameAttribute1.getFieldName())) {
                action.put("single6", "2553");
            } else {
                action.put("single6", "2554");
            }
            action.put("shotType", "ONESELF");
            action.put("goodsCatalogueId", 6);
            action.put("bargain", true);
            action.put("compensation", true);
            String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
            if ("安卓QQ".equals(regional)) {
                action.put("single1", 526);//操作系统
            } else if ("苹果QQ".equals(regional)) {
                action.put("single1", 527);//操作系统
            } else if ("安卓微信".equals(regional)) {
                action.put("single1", 528);//操作系统
            } else if ("苹果微信".equals(regional)) {
                action.put("single1", 529);//操作系统
            } else {
                action.put("single1", 526);//操作系统
            }
        }
        else if ("逆战".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 14);
            action.put("gameAccount", goodsInfoAndAttrValueDto.getId());
            action.put("accountSource", "ORIGINAL_USER");

            action.put("detailsSingle1", "1293");
            if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF1())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF1()));
                if (gameAttribute1.getFieldName().equals("可实名")) {
                    action.put("detailsSingle2", "7593");
                } else {
                    action.put("detailsSingle2", "7594");
                }
            }
            action.put("shotType", "ONESELF");
            action.put("goodsCatalogueId", 6);
            action.put("bargain", true);
            action.put("compensation", true);
            String regional = goodsInfoAndAttrValueDto.getGroupName();
            if (Objects.equals("网通区", regional)) {
                action.put("single1", 896);//操作系统
            }
            if (Objects.equals("电信区", regional)) {
                action.put("single1", 895);//操作系统
            }
        }
        else if ("火影忍者".equals(goodsInfoAndAttrValueDto.getGameName())) {
            action.put("gameId", 11);
            action.put("shotType", "ONESELF");
            action.put("detailsSingle1", "1293");
            action.put("detailsSingle2", "13950");
            String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
            if ("安卓QQ".equals(regional)) {
                action.put("single1", 530);//操作系统
            } else if ("苹果QQ".equals(regional)) {
                action.put("single1", 531);//操作系统
            } else if ("安卓微信".equals(regional)) {
                action.put("single1", 532);//操作系统
            } else if ("苹果微信".equals(regional)) {
                action.put("single1", 533);//操作系统
            } else {
                action.put("single1", 1600);//操作系统
            }
            if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                if (gameAttribute1.getFieldName().equals("可改二次")) {
                    action.put("single4", "7418");
                } else {
                    action.put("single4", "7419");
                }
            } else {
                action.put("single4", "7419");
            }
            action.put("single5", "12062");
            action.put("compensation", "true");
            action.put("bargain", "true");
        }
        else if (goodsInfoAndAttrValueDto.getGameName().equals("光遇")) {
            action.put("gameId", 41);
            if (goodsInfoAndAttrValueDto.getCarrierName().equals("网易手机")) {
                action.put("single4", 4246);
            } else {
                action.put("single4", 4247);
            }
            action.put("detailsSingle1", 4674);
            action.put("detailsSingle2", 9627);
            if (goodsInfoAndAttrValueDto.getSystemName().equals("安卓")) {
                action.put("single1", 2157);
                action.put("single2", 2159);
            } else {
                action.put("single1", 2156);
                action.put("single2", 2158);
            }
        }
        else if (goodsInfoAndAttrValueDto.getGameName().equals("蛋仔派对")) {
            action.put("gameId", 91);
            if (goodsInfoAndAttrValueDto.getSystemName().equals("安卓")) {
                action.put("single1", 4996);
                action.put("single2", 5905);
            }else{
                action.put("single1", 4997);
                action.put("single2", 6275);
            }
            action.put("detailsSingle1", 9629);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())){
                String dw = "[{\"key\":5006,\"value\":\"一阶鹌鹑蛋\"},{\"key\":5007,\"value\":\"二阶鸽子蛋\"},{\"key\":5008,\"value\":\"三阶鸡蛋\"},{\"key\":5009,\"value\":\"四阶鹅蛋\"},{\"key\":5010,\"value\":\"五阶鸵鸟蛋\"},{\"key\":5011,\"value\":\"六阶恐龙蛋\"},{\"key\":5012,\"value\":\"巅峰凤凰蛋\"},{\"key\":9819,\"value\":\"超级凤凰蛋\"},{\"key\":9820,\"value\":\"无敌凤凰蛋\"}]\n";
                JSONArray jsonArray = JSONArray.parseArray(dw);
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF5()));
                for(Object o : jsonArray){
                    if(JSONObject.parseObject(o.toString()).getString("value").equals(gameAttribute1.getFieldName())){
                        action.put("single4", JSONObject.parseObject(o.toString()).getString("key"));
                    }
                }
            }else{
                action.put("single4",5006);
            }
        }
        else if (goodsInfoAndAttrValueDto.getGameName().equals("英雄联盟(手游)")) {
            action.put("gameId", 17);
            String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
            if ("安卓QQ".equals(regional)) {
                action.put("single1", 945);//操作系统
            } else if ("苹果QQ".equals(regional)) {
                action.put("single1", 946);//操作系统
            } else if ("安卓微信".equals(regional)) {
                action.put("single1", 948);//操作系统
            } else if ("苹果微信".equals(regional)) {
                action.put("single1", 949);//操作系统
            }
            action.put("detailsSingle3", 13956);
            action.put("single4", 14031);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF4())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF4()));
                if(gameAttribute1.getFieldName().equals("可二次实名")) {
                    action.put("detailsSingle2", 7595);
                }else {
                    action.put("detailsSingle2", 7596);
                }
            }else {
                action.put("detailsSingle2", 7596);
            }
            action.put("detailsSingle1", 1355);
        }
        else if (goodsInfoAndAttrValueDto.getGameName().equals("暗区突围")){
            action.put("gameId", 77);
            if(goodsInfoAndAttrValueDto.getSystemName().equals("安卓")){
                action.put("single1", 6723);
                if(goodsInfoAndAttrValueDto.getCarrierName().equals("QQ")){
                    action.put("single2", 6725);
                }else {
                    action.put("single2", 6726);
                }
            }else {
                action.put("single1", 6724);
                if(goodsInfoAndAttrValueDto.getCarrierName().equals("QQ")){
                    action.put("single2", 6727);
                }else {
                    action.put("single2", 6728);
                }
            }
            action.put("detailsSingle2", 13949);
            action.put("single4", 14033);

            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                if(gameAttribute1.getFieldName().equals("可二次")) {
                    action.put("single5", 15408);
                }else {
                    action.put("single5", 15409);
                }
            }else {
                action.put("single5", 15408);
            }
        }
        else if (goodsInfoAndAttrValueDto.getGameName().equals("三角洲行动")){
            action.put("gameId", 391);
            action.put("single1", 13851);
            if(goodsInfoAndAttrValueDto.getCarrierName().equals("QQ")){
                action.put("single2", 13852);
            }else {
                action.put("single2", 13853);
            }
            action.put("detailsSingle2", 13976);
            action.put("shotType", "PZDS_OFFICIAL");
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF7())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF7()));
                if(gameAttribute1.getFieldName().equals("可二次实名")) {
                    action.put("single4", 13200);
                }else {
                    action.put("single4", 13201);
                }
            }
            action.put("detailsSingle1", 13202);
        }
        else {
            throw new GlobalException("盼之接口不支持此游戏：" + goodsInfoAndAttrValueDto.getGameName());
        }
        params.put("action", action);
        params.put("timestamp", System.currentTimeMillis() + "");
        String cover = getCover(action) + "timestamp=" + params.get("timestamp").toString() + "&key=" + sa.getSaleKey();
        log.info("cover={}", cover);
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign", sign);
        return params;
    }

    private Map<String, Object> wzryParams(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, Map<String, Object> action) {
        GameAttribute gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF16()));
        action.put("gameId", 7);
        action.put("detailsText1", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())?goodsInfoAndAttrValueDto.getF17():"0");
        action.put("detailsSection1", goodsInfoAndAttrValueDto.getPrice().toPlainString());
        if ("可二次实名".equals(gameAttribute.getFieldName())) {
            action.put("single4", 2164);
        } else if ("包人脸".equals(gameAttribute.getFieldName())) {
            action.put("single4", 2561);
        } else {
            action.put("single4", 2165);
        }
        action.put("single5", 11468);
        action.put("single6", 12067);
        action.put("section2", 0);//荣耀水晶数
        action.put("section1", null == goodsInfoAndAttrValueDto.getF8() ? 0 : goodsInfoAndAttrValueDto.getF8());// 皮肤数
        //1466金色仲夏夜1467幽冥之眼1468幽冥火1469幻海之心1470未来机甲1471零号雷霆1475时之愿境2560无
        action.put("detailsCheckbox2", new String[]{"2560"});
        //3514 皮肤1 3515皮肤2 3516皮肤3 3517皮肤4
        action.put("detailsCheckbox1", new String[]{"3514"});//星元皮肤1
        //安卓Q 苹果Q 安卓WX 苹果WX
        String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
        if ("安卓QQ".equals(regional)) {
            action.put("single1", 246);//操作系统
        } else if ("苹果QQ".equals(regional)) {
            action.put("single1", 247);//操作系统
        } else if ("安卓微信".equals(regional)) {
            action.put("single1", 248);//操作系统
        } else if ("苹果微信".equals(regional)) {
            action.put("single1", 249);//操作系统
        } else {
            action.put("single1", 1600);//操作系统
        }
        action.put("single2", 1600);//服务器 获取不到 默认赋值1600
        action.put("detailsSingle1", 13210);
        if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())){
            GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
            String string = "[{\"key\":12051,\"value\":\"10\"},{\"key\":12052,\"value\":\"9\"},{\"key\":12053,\"value\":\"8\"},{\"key\":12054,\"value\":\"7\"},{\"key\":12055,\"value\":\"6\"},{\"key\":12056,\"value\":\"5\"},{\"key\":12057,\"value\":\"4\"},{\"key\":12058,\"value\":\"3\"},{\"key\":12059,\"value\":\"2\"},{\"key\":12060,\"value\":\"1\"},{\"key\":12061,\"value\":\"0\"}]\n";
            JSONArray jsonArray = JSONArray.parseArray(string);
            for(Object o : jsonArray){
                if(gameAttribute1.getFieldName().replace("V","").replace("无","1").equals(JSONObject.parseObject(o.toString()).getString("value"))){
                    action.put("detailsSingle2", JSONObject.parseObject(o.toString()).getInteger("key"));
                }
            }
        }else{
            action.put("detailsSingle2", 12061);
        }
        action.put("detailsSingle3", 13944);
        action.put("section4", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())?goodsInfoAndAttrValueDto.getF12().split(",").length:"0");
        return action;
    }

    @Override
    public AjaxResult addGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, salePartner);
        String paramsStr = JSONObject.toJSONString(params);
        log.info("盼之新增请求参数={}", paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + PZ_ADD_URL, paramsStr, "application/json");
        log.info("盼之新增返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        String msg = resultJson.getString("info");
        String data = resultJson.getString("data");
        msg = MapUntils.unicodeToString(msg);

        Map<String, Object> result = new HashMap<>();

        if (!resultJson.getBoolean("success")) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
            result.put("outId", JSONObject.parseObject(data).getString("outGoodsNo"));
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", msg);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner sa) {

        Map<String, Object> action = new TreeMap<>();
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(sa.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        action.put("outGoodsNo", artRecs.get(0).getOutid());
        action.put("price", goodsInfoAndAttrValueDto.getPrice().stripTrailingZeros().toPlainString());

        action.put("remark", "修改");
        Map<String, Object> params = new HashMap<>();
        params.put("proxyId", null == sa.getOther() ? PZ_PROXY_ID : sa.getOther());
        params.put("action", action);
        params.put("timestamp", System.currentTimeMillis() + "");

        String cover = getCover(action) + "timestamp=" + params.get("timestamp").toString() + "&key=" + sa.getSaleKey();
        ;
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign", sign);
        String paramsStr = JSONObject.toJSONString(params);

        log.info("盼之修改商品价格请求参数={}", paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + PZ_MOD_URL, paramsStr, "application/json");
        log.info("盼之修改商品价格返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        String msg = resultJson.getString("info");
        msg = MapUntils.unicodeToString(msg);

        Map<String, Object> result = new HashMap<>();

        if (!resultJson.getBoolean("success")) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", msg);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult delGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner sa) {
        Map<String, Object> action = new TreeMap<>();
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(sa.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        action.put("outGoodsNo", artRecs.get(0).getOutid());
        action.put("remark", "下架商品");
        Map<String, Object> params = new HashMap<>();
        params.put("proxyId", null == sa.getOther() ? PZ_PROXY_ID : sa.getOther());
        params.put("action", action);
        params.put("timestamp", System.currentTimeMillis() + "");

        String cover = getCover(action) + "timestamp=" + params.get("timestamp").toString() + "&key=" + sa.getSaleKey();
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign", sign);
        String paramsStr = JSONObject.toJSONString(params);

        log.info("盼之下架请求参数={}", paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + PZ_DEL_URL, paramsStr, "application/json");
        log.info("盼之下架返回参数={}", response);

        JSONObject resultJson = JSONObject.parseObject(response);
        String msg = resultJson.getString("info");
        msg = MapUntils.unicodeToString(msg);

        Map<String, Object> result = new HashMap<>();

        if (!resultJson.getBoolean("success")) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", msg);
        return AjaxResult.success(result);
    }

    private List<GameAttribute> getGameAttributs(String ids) {
        if (StringUtils.isEmpty(ids)) {
            return new ArrayList<>();
        }
        return gameAttributeMapper.selectGameAttributeListByIds((Long[]) ConvertUtils.convert(ids.split(","),
                Long.class));
    }

    private String reIds(String allIds, String ids) {
        if (StringUtils.isNotEmpty(ids)) {
            if (StringUtils.isNotEmpty(allIds)) {
                allIds = allIds + "," + ids;
            } else {
                allIds = ids;
            }
        }
        return allIds;
    }

    public static void main(String[] args) {

//        Map<String, Object> action = new TreeMap<>();
//        action.put("goodsCatalogueId", 6);
//        action.put("gameId", 25);
////        action.put("proxyId", "18093522409");
//        Map<String, Object> params = new HashMap<>();
//        params.put("proxyId", "18093522409");
//        params.put("action", action);
//        params.put("timestamp", 1658153198368L + "");
//
//        String proxyKey = "pzds_open_api_sign_A536AF99048D6484650091B84CD48FA9";
////        String proxyKey = "pzds_open_api_sign_3430E933C35AD3AC1820D23485CBE64E";
//
//        String cover = getCover(action) + "timestamp=" + params.get("timestamp").toString() + "&key=" + proxyKey;
//        String sign = DigestUtils.md5Hex(cover).toUpperCase();
//        log.info(sign);
//        log.info(cover);
//        params.put("sign", sign);
//        log.info(JSONObject.toJSONString(params));
//        String response = "";
//        response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + "/api/openData/cooperateGameGoods", JSONObject.toJSONString(params), "application/json");
//        log.info(response);
//        response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + "/api/openData/getGameGoodsPropertyConfig", JSONObject.toJSONString(params), "application/json");
//        log.info(response);
//        response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + "/api/openData/listTreeProperty", JSONObject.toJSONString(params), "application/json");
//        log.info(response);
//        response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + "/api/openData/listPropertyOption", JSONObject.toJSONString(params), "application/json");
//        log.info(response);
        selectError("27097834");
    }
    static void selectError(String outGoodsNo){
        Map<String, Object> action = new TreeMap<>();
        action.put("outGoodsNo", outGoodsNo);
        action.put("gameId", 77);
//        action.put("serialVersionUID", 1);
        Map<String, Object> params = new HashMap<>();
        params.put("proxyId", "18093522409");
        params.put("action", action);
        params.put("timestamp", System.currentTimeMillis() + "");

        String cover = getCover(action) + "timestamp=" + params.get("timestamp").toString() + "&key=" + "pzds_open_api_sign_A536AF99048D6484650091B84CD48FA9";
        System.out.println(cover);
        String sign = DigestUtils.md5Hex(cover).toUpperCase();
        params.put("sign", sign);
        String paramsStr = JSONObject.toJSONString(params);

        log.info("盼之下架请求参数={}", paramsStr);
        String response = HttpUtils.sendPost(OutUrlConstant.PANZHIURL + "/api/openData/goodsErrorInfo", paramsStr, "application/json");
        log.info(response);
    }
}
